<template>
  <div class="goods-hot">
    <h3 v-if="type === 1">24小时热榜</h3>
    <h3 v-else-if="type === 2">周热榜</h3>
    <h3 v-else-if="type === 3">总榜</h3>
    <!-- 商品区块 -->
    <div class="list">
      <GoodsItem v-for="item in list" :key="item.id" :goods="item" />
    </div>
  </div>
</template>

<script>
import GoodsItem from '@/views/Category/components/goods-item.vue'
import { findGoodsHot } from '@/api/goods'
import { ref } from 'vue'
export default {
  components: { GoodsItem },
  name: 'GoodsHot',
  props: {
    type: {
      type: Number,
      default: 1
    },
    goodsId: {
      type: String
    }
  },
  setup (props) {
    const list = ref([])
    findGoodsHot({ id: props.goodsId, type: props.type }).then(({ result }) => {
      console.log(result)
      list.value = result
    })
    return { list }
  }
}
</script>

<style scoped lang="less">
.goods-hot {
  h3 {
    height: 70px;
    background: @helpColor;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: normal;
  }
  .list {
    background-color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
}
</style>
